//工单分类
const wo_cate = [{
  id: 1,
  title: '设备维修'
},{
  id: 2,
  title: '桌面维护'
},]
//用户
const users = [{
  id:1,
  username: 'user1',
  full_name: '郑少秋',
  dept: '部门1',
  mobile: '12345678901',
  address: 'XX楼'
},{
  id:2,
  username: 'user2',
  full_name: '赵雅芝',
  dept: '部门2',
  mobile: '12345678903',
  address: 'YY楼'
},]
//服务人员
const workers = [{
  id:3,
  username: 'user3',
  full_name: '周润发',
  dept: '运维部',
  mobile: '12345678902',
  address: 'BD楼'
},{
  id:4,
  username: 'user4',
  full_name: '刘德华',
  dept: '运维部',
  mobile: '12345678903',
  address: 'BD楼'
},]
//资源
const resources = [{
  id:2,
  cate: {
      id:1,
      parent: {
          title: 'IT设备'
      },
      title: '主机',
      unit: '台'
  },
  model: 'XX型号',
  spec: 'XX格',
  brand: 'DELL',
  sn: 'HSYYE02083930',
  address: '某个位置'
},]
//图片
const images = [{
  id:1,
  title:'图片1',
  url:'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3153379203,2591872731&fm=26&gp=0.jpg'
},{
  id:2,
  title:'图片2',
  url:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595845912051&di=ada02fc09013be8f8bf4472833b9d0a5&imgtype=0&src=http%3A%2F%2Fh.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Fd439b6003af33a871e5d5756c25c10385343b54e.jpg'
},{
  id:3,
  title:'图片3',
  url:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1595845952795&di=1c0a521956817fb3a5a4a9d20524dea7&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Ffront20200720ac%2F400%2Fw1600h1200%2F20200720%2F2a90-iwpcxks5198659.jpg'
}
]
//工单
const wo_list = [{
  id:1,
  cate: wo_cate[0],
  code: '200727010003',
  customer: users[0],
  dispatcher: workers[0],
  worker: workers[1],
  res: resources[0],
  desc:'设备故障，描述问题，此处可能很多文字，所以应该用Text字段，前端应该表现为TextArea元素',
  images:images.slice(0,3),
  create_datetime:'2020-07-27 18:16:56',
  status:'started',
  rank:null
},{
  id:2,
  cate: wo_cate[2],
  code: '200910010002',
  customer: users[0],
  dispatcher: workers[0],
  worker: workers[1],
  res: resources[0],
  desc:'桌面问题，描述问题，此处可能很多文字，所以应该用Text字段，前端应该表现为TextArea元素',
  images:images.slice(1,3),
  create_datetime:'2020-07-28 09:26:57',
  status:'finished',
  rank:null
},{
  id:3,
  cate: wo_cate[2],
  code: '200910010001',
  customer: users[0],
  dispatcher: workers[0],
  worker: workers[1],
  res: resources[0],
  desc:'桌面问题，描述问题，此处可能很多文字，所以应该用Text字段，前端应该表现为TextArea元素',
  images:images.slice(1,2),
  create_datetime:'2020-07-28 09:26:57',
  status:'closed',
  rank:5
}]
//工单流程
const wo_flow_list = [{
  id:1,
  work_order:wo_list[0],
  action:'start',
  comment:users[0].full_name+'\t\t提交工单\n',
  from:users[0],
  to:users[1],
  pre:null,
  next:{
    id:9
  },
  create_datetime:'2020-07-27 18:16:56',
  submit_datetime:'2020-07-27 20:16:56',
  attitude: 'passed'
},{
  id:9,
  work_order:wo_list[1],
  action:'finish',
  comment:workers[1].full_name+'\t\t完成工单',
  from:users[0],
  to:users[1],
  pre:{
      id:9
  },
  next:{
    id: 10
  },
  create_datetime:'2020-07-27 18:16:56',
  submit_datetime:'2020-07-28 16:16:56',
  attitude:'passed'
},{
  id:10,
  work_order:wo_list[1],
  action:'finish',
  comment:'等待确认',
  from:users[0],
  to:users[1],
  pre:{
      id:9
  },
  next:null,
  create_datetime:'2020-07-27 18:16:56',
  submit_datetime:null,
  attitude:null
}]

const mock = {
  login2: (req, res) => {
      res.json({
          status: 200,
          list: [{
              token: "y67_@dcnjbyi090YTR%67iub"
          }],
          pager: null,
          message: ""
      })
  },
  todo: (req, res) => {
      //构造list
      const list = wo_flow_list
      res.json({
          status: 200,
          list: list,
          pager: null,
          message: ""
      })
  },
  history:(req, res) => {
      //构造list
      const list = wo_list.slice(2,3)
      res.json({
          status: 200,
          list: list,
          pager: null,
          message: ""
      })
  },
  flow:(req, res) => {
    //构造list
    let list = []
    wo_flow_list.forEach(flow=>{
      let f = Object.assign({},flow)
      delete f.work_order
      list.push(f)
    })
    res.json({
        status: 200,
        list: list,
        pager: null,
        message: ""
    })
},
}

module.exports = mock
